package com.jzo2o.customer.controller.worker;


import com.jzo2o.common.utils.UserContext;
import com.jzo2o.customer.enums.BankAccountTypeEnum;
import com.jzo2o.customer.model.dto.request.BankAccountUpsertReqDTO;
import com.jzo2o.customer.model.dto.response.BankAccountResDTO;
import com.jzo2o.customer.service.IBankAccountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 银行账户 前端控制器
 * </p>
 *
 * @author jzh
 * @since 2025-08-08
 */
@RestController("workerBankAccountController")
@RequestMapping("/worker/bank-account")
@Api(tags = "服务端 - 服务人员银行账号信息相关接口")
public class BankAccountController {

    @Resource
    private IBankAccountService bankAccountService;

    @ApiOperation("新增或更新银行账号信息")
    @PostMapping
    public void bankAccount(@RequestBody BankAccountUpsertReqDTO bankAccountUpsertReqDTO) {
        Long id = UserContext.getCurrentUser().getId();
        bankAccountUpsertReqDTO.setId(id);
        bankAccountUpsertReqDTO.setType(BankAccountTypeEnum.WORKER.getType());
        bankAccountService.bankAccount(bankAccountUpsertReqDTO);
    }

    @ApiOperation("获取当前用户银行账号")
    @GetMapping("/currentUserBankAccount")
    public BankAccountResDTO currentUserBankAccount() {
        return bankAccountService.currentUserBankAccount();
    }

}
